<template>
  <div class="home">
    home页
   {{ num }}
   {{ this.$store.state.a.num }}
  </div>
</template>
<script>
import { mapState,mapMutations } from 'vuex'
export default {
  name: 'Home',
  mounted () {
     //this.addNum();
    // this['a/addNum']();
    this.$store.commit("a/addNum");
  },
  methods:{
    // ...mapMutations(['addNum'])
    //模块化加命名空间
    // ...mapMutations(['a/addNum'])
    // ...mapMutations('a',['addNum'])
    ...mapMutations({
      addNum:"a/addNum"
    })
  },
  computed: {
    ...mapState({
      num:(state)=>state.a.num
    })
  }
}
</script>
